package com.zcup.designer.behavior.observer;

public class ConcreteObserver extends Observer {
    private String name;
    private int observerState;
    private ConcreteSubject concreteSubject;

    public ConcreteObserver(String name, ConcreteSubject concreteSubject) {
        this.name = name;
        this.concreteSubject = concreteSubject;
    }

    @Override
    void update() {
        observerState = concreteSubject.subjectState;
        System.out.println(getName() + "\t" + observerState);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getObserverState() {
        return observerState;
    }

    public void setObserverState(int observerState) {
        this.observerState = observerState;
    }

    public ConcreteSubject getConcreteSubject() {
        return concreteSubject;
    }

    public void setConcreteSubject(ConcreteSubject concreteSubject) {
        this.concreteSubject = concreteSubject;
    }
}
